


project, uses(../data_output/termlimited.dta)
		
	
		use ../data_output/termlimited.dta	, clear
		keep CandId chamber_term rating* sig_name* sig_issues* termlimited party terms_in_office
		reshape long rating sig_name sig_issues, i(CandId chamber_term) j(sig_id)
		
		

		gen dem_est = .
		gen dem_upper95 = .
		gen dem_lower95 = .
		gen dem_upper90 = .
		gen dem_lower90 = .

		gen rep_est = .
		gen rep_upper95 = .
		gen rep_lower95 = .
		gen rep_upper90 = .
		gen rep_lower90 = .		
		
		gen group = .
	
	
		egen CandId_sig = group(CandId sig_id)
		egen chamber_term_sig = group(chamber_term sig_id)
	

	
		forval i = 1/8 {
	
		reghdfe rating c.termlimited if party=="Dem" & sig_issue==`i' , a(CandId_sig chamber_term_sig )  cluster(CandId) // NRA & matchrate_`v'>0.75
		replace dem_est = _b[termlimited] if _n==`i'
		replace dem_upper95 = _b[termlimited] + 1.96*_se[termlimited] if _n==`i'
		replace dem_lower95 = _b[termlimited] - 1.96*_se[termlimited] if _n==`i'
		replace dem_upper90 = _b[termlimited] + 1.64*_se[termlimited] if _n==`i'
		replace dem_lower90 = _b[termlimited] - 1.64*_se[termlimited] if _n==`i'		
		
		
		
		reghdfe rating c.termlimited if party=="Rep" & sig_issue==`i' , a(CandId_sig chamber_term_sig )  cluster(CandId) // NRA & matchrate_`v'>0.75
		replace rep_est = _b[termlimited] if _n==`i'
		replace rep_upper95 = _b[termlimited] + 1.96*_se[termlimited] if _n==`i'
		replace rep_lower95 = _b[termlimited] - 1.96*_se[termlimited] if _n==`i'
		replace rep_upper90 = _b[termlimited] + 1.64*_se[termlimited] if _n==`i'
		replace rep_lower90 = _b[termlimited] - 1.64*_se[termlimited] if _n==`i'		
				
		replace group = `i'  if _n==`i'	
		

		}

		label define issues 1 "Abortion"  2	"Business" 3 "Education" 4 "Environment" 5 "Guns" 6 "Other" 7 "Taxes" 8 "Labor Unions"
		label values  group issues		
		
		keep if dem_est!=.
		gen n_rep = group+0.15


					

			
twoway 	(rspike dem_upper95 dem_lower95 group,  horizontal lwidth(thin)   	lcolor(blue) ylabel(1(1)8 , valuelabel angle(0) ) ) || ///
		(rspike dem_upper90 dem_lower90 group,  horizontal lwidth(medthick) 	lcolor(blue) ) || ///
		(dot dem_est group ,horizontal  ndots(1) msymbol(square) msize(medlarge) mfcolor(white) mcolor(blue) ) || ///
		(rspike rep_upper95 rep_lower95 n_rep,  horizontal lwidth(thin)   	lcolor(red) ) || ///
		(rspike rep_upper90 rep_lower90 n_rep,  horizontal lwidth(medthick) 	lcolor(red) ) || ///
		(dot rep_est n_rep ,horizontal  ndots(1) msymbol(circle) msize(medlarge) mfcolor(white) mcolor(red) ) ///
		, xline(0, lcolor(black) lpattern(solid)) graphregion(color(white)) bgcolor(white) ///
		legend(order(3 "Democrats" 6 "Republicans") pos(12) )  ysc(outergap(5)) xlabel(-6 (1) 6 ) yscale(reverse) ///
		xtitle("Effect of Being Term Limited on Interest Group Ratings (0-100)") 
		graph export ../tables_figures/ratings.pdf , replace
		
		
		
		